home *** CD-ROM | disk | FTP | other *** search
- Path: csugrad.cs.vt.edu!not-for-mail
- From: rsuri@csugrad.cs.vt.edu (Raj Suri)
- Newsgroups: comp.lang.c++
- Subject: Template constructor problem
- Date: 30 Mar 1996 13:11:27 -0500
- Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
- Message-ID: <4jjtgf$ebo@csugrad.cs.vt.edu>
- NNTP-Posting-Host: csugrad.cs.vt.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Ok, take this code using g++ v2.7
-
- queue.h:
-
- template <class QueueItem> class Queue {
- private:
- QueueItem buffer[100];
- int head, tail, count;
-
- public:
- Queue();
- void Insert (QueueItem item);
- QueueItem Remove();
- int Size();
- ~Queue();
- };
-
- template <class QueueItem>
- Queue<QueueItem>::Queue() : count(0), head(0), tail(0) {}
-
- .....[the rest of the mothods]
-
-
- main.cc:
-
- #include<stdio.h>
- #include "queue.h"
-
- Queue<int> myqueue;
-
- main () {
-
- }
-
-
- Compiler error when linking:
- collect2: ld returned 1 exit status
- /usr/lib/cmplrs/cc/ld:
- Undefined:
- Queue<int>::Queue(void)
-
-
- If I don't declare a queue object, then I don't get the linker error.
- Any suggestion?? Thanks in advance.
-
- -Raj
-
-